package com.p2p.front.dal.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.p2p.base.dao.BaseMapper;
import com.p2p.front.dal.model.LoanPhoto;

public interface LoanPhotoDao extends BaseMapper {
	
	@Insert("insert into p2p_loan_photo(no,lid,uid,url,addtime,status,type) "
			+ "values(#{no},#{lid},#{uid},#{url},#{addtime},#{status},#{type})") 
	void save(LoanPhoto loanPhoto);
	
	@Select("select id,no,lid,uid,url,addtime,status,type from p2p_loan_photo where lid = #{lid}")
	List<LoanPhoto> findByLid(Long lid);
	
	@Select("select id,no,lid,uid,url,addtime,status,type from p2p_loan_photo where lid = #{lid} and type=#{type}")
	List<LoanPhoto> findByLidAndType(@Param("lid")Long lid,@Param("type")Integer type);
	
	List<LoanPhoto> findByLidList(List<Long> lidList);
	
	List<LoanPhoto> findByLidListAndType(@Param("lidList")List<Long> lidList,@Param("type")Integer type);
	
	@Select("select id,no,lid,uid,url,addtime,status,type from p2p_loan_photo where id = #{id}")
	LoanPhoto findById(Long id);
	
	@Delete("delete from p2p_loan_photo where id =#{id}")
	void deleteById(Long id);
	
	@Update("update p2p_loan_photo set status = #{status} where id =#{id}")
	void updateImageStatus(@Param("id")Long id, @Param("status")int status);
	
	@Select("select id,no,lid,uid,url,addtime,status,type from p2p_loan_photo where status = 1")
	List<LoanPhoto> findList();

}
